<template>
  <div class="prison-data">
    <div class="data-header">
      <h3>监区数据</h3>
    </div>
    <div class="data-content">
      <div class="data-entry" v-for="(entry, index) in prisonData" :key="index">
        <div class="entry-message" @click="handleEntryClick(entry, index)">
          {{ entry.message }}
        </div>
        <div class="entry-indicator" v-if="entry.type === 'transfer'">
          <span class="transfer-icon">↗️</span>
        </div>
      </div>
    </div>

    <!-- 详细信息弹窗 -->
    <div v-if="showDetail" class="detail-modal" @click="closeDetail">
      <div class="detail-content" @click.stop>
        <div class="detail-header">
          <h4>详细信息</h4>
          <button class="close-btn" @click="closeDetail">×</button>
        </div>
        <div class="detail-body">
          <p>{{ detailMessage }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PrisonData',
  data() {
    return {
      prisonData: [
        {
          message: '罪犯汪天实收押至第四监区',
          type: 'admission'
        },
        {
          message: '罪犯李乐乐收押至第三监区',
          type: 'admission'
        },
        {
          message: '罪犯俞杰从第十监区调转到第一监区',
          type: 'transfer',
          detail: '罪犯俞杰在第十监区有同案犯'
        }
      ],
      showDetail: false,
      detailMessage: ''
    }
  },
  methods: {
    handleEntryClick(entry, index) {
      if (entry.type === 'transfer' && entry.detail) {
        this.detailMessage = entry.detail
        this.showDetail = true
      }
    },

    closeDetail() {
      this.showDetail = false
      this.detailMessage = ''
    }
  }
}
</script>

<style scoped>
.prison-data {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 15px;
}

.data-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-shrink: 0;
}

.data-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(45deg,
    rgba(0, 120, 160, 0.9) 0%,
    rgba(0, 100, 140, 0.8) 50%,
    rgba(0, 80, 120, 0.7) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 10px rgba(0, 100, 150, 0.4);
}

.data-content {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
}

.data-entry {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  margin-bottom: 8px;
  background:
    linear-gradient(145deg,
      rgba(0, 80, 120, 0.08) 0%,
      rgba(0, 100, 140, 0.06) 50%,
      rgba(0, 60, 100, 0.04) 100%
    ),
    rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border: 1px solid rgba(0, 100, 150, 0.2);
  backdrop-filter: blur(6px);
  transition: all 0.3s ease;
}

.data-entry:hover {
  background:
    linear-gradient(145deg,
      rgba(0, 80, 120, 0.12) 0%,
      rgba(0, 100, 140, 0.1) 50%,
      rgba(0, 60, 100, 0.06) 100%
    ),
    rgba(0, 0, 0, 0.4);
  border-color: rgba(0, 100, 150, 0.3);
  transform: translateX(2px);
}

.entry-message {
  flex: 1;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.4;
  cursor: pointer;
}

.entry-message:hover {
  color: #00ffff;
}

.entry-indicator {
  margin-left: 10px;
}

.transfer-icon {
  font-size: 16px;
  opacity: 0.7;
}

/* 弹窗样式 */
.detail-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.detail-content {
  background:
    linear-gradient(145deg,
      rgba(0, 80, 120, 0.15) 0%,
      rgba(0, 100, 140, 0.12) 50%,
      rgba(0, 60, 100, 0.08) 100%
    ),
    rgba(0, 0, 0, 0.8);
  border-radius: 12px;
  border: 1px solid rgba(0, 100, 150, 0.3);
  padding: 20px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 100, 150, 0.3);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.detail-header h4 {
  margin: 0;
  font-size: 18px;
  color: #00ffff;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ff6b6b;
}

.detail-body p {
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.6;
}

/* 自定义滚动条 */
.data-content::-webkit-scrollbar {
  width: 6px;
}

.data-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.data-content::-webkit-scrollbar-thumb {
  background: rgba(0, 100, 150, 0.5);
  border-radius: 3px;
}

.data-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 100, 150, 0.7);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .prison-data {
    padding: 10px;
  }

  .data-header h3 {
    font-size: 14px;
  }

  .data-entry {
    padding: 10px 12px;
  }

  .entry-message {
    font-size: 13px;
  }

  .detail-content {
    padding: 15px;
    max-width: 350px;
  }

  .detail-header h4 {
    font-size: 16px;
  }
}
</style>
